<?php
namespace app\common\model;

use think\Model;

class Page extends Model
{
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';


    public function files()
    {
        return $this->belongsToMany(Files::class, PageFiles::class);
    }


	public function searchTitleAttr($query, $value, $data)
    {
        $query->where('title','like', '%'.$value.'%');
    }



    public function getStatusTextAttr($value,$data)
    {
        $status = [0=>'禁用',1=>'正常'];
        return $status[$data['status']];
    }


    public function getTemplateAttr($value)
    {
        return $value.'.html';
    }

	public function setTemplateAttr($value, $data)
    {
        return str_replace('.html','',$value);
    }

}